from django.db import models
import enum


class RequestMethod(enum.Enum):
    GET = 1
    OTHERS = 2


class Permission(models.Model):
    url = models.CharField(max_length=1024)
    request_method = models.SmallIntegerField()
    allowed_page_id = models.CharField(max_length=1024)  # '0': request free api
    min_role_level = models.SmallIntegerField()
    desc = models.CharField(max_length=1024)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)


class MenuNode(models.Model):
    merchant_id = models.IntegerField()
    section_id = models.CharField(max_length=32, unique=True)
    section_name = models.CharField(max_length=128)
    tree_path = models.CharField(max_length=128)
    parent_section_id = models.IntegerField()
    priority = models.IntegerField()
    is_page = models.BooleanField()  # 頁面節點
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)


class PageBlockField(models.Model):
    role_id = models.IntegerField()
    menu_node_id = models.IntegerField()
    exclude_field_name = models.CharField(max_length=32)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

